package bb.lanxing.view.dialog;

import android.app.ProgressDialog;
import android.content.Context;
import android.view.Window;

import androidx.annotation.NonNull;

import bb.lanxing.R;
import bb.lanxing.activity.interfaces.IBaseDialog;


public class CustomProgressDialog implements IBaseDialog {
    private final Context context;
    private ProgressDialog mDialog;

    public CustomProgressDialog(@NonNull Context context) {
        this.context = context;
    }

    @Override
    public void showLoading() {
        if (mDialog != null && mDialog.isShowing()) {
            return;
        }
        mDialog = new ProgressDialog(context);
        mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        mDialog.setCanceledOnTouchOutside(false);
        mDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        mDialog.setMessage(context.getString(R.string.progress_tips_def));
        mDialog.show();
    }

    @Override
    public void dismissLoading() {
        if (mDialog != null && mDialog.isShowing()) {
            mDialog.dismiss();
        }
    }
}
